package com.surenpi.jenkins.client.computer;

import com.google.common.base.Function;
import com.google.common.collect.Maps;
import com.surenpi.jenkins.client.BaseManager;
import java.io.IOException;
import java.util.List;
import java.util.Map;

public class Computers extends BaseManager {
   public Map<String, Computer> getComputers() throws IOException {
      List<Computer> computers = ((Computer)this.getClient().get("computer/", Computer.class)).getComputers();
      return Maps.uniqueIndex(computers, new Function<Computer, String>() {
         public String apply(Computer computer) {
            computer.setClient(Computers.this.getClient());
            return computer.getDisplayName().toLowerCase();
         }
      });
   }

   public ComputerSet getComputerSet() throws IOException {
      ComputerSet computerSet = (ComputerSet)this.getClient().get("computer/?depth=2", ComputerSet.class);
      computerSet.setClient(this.getClient());
      return computerSet;
   }

   protected String[] getDependencyArray() {
      return null;
   }
}
